import os
from google.appengine.ext.webapp import template

import cgi
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class EmbedPage(webapp.RequestHandler):
  def get(self):
    title = cgi.escape(self.request.get('t'))
    wave_id = cgi.escape(self.request.get('id'))
    width = cgi.escape(self.request.get('w'))
    height = cgi.escape(self.request.get('h'))
    theme_id = cgi.escape(self.request.get('th'))
      
    template_values = {
                       'title': title,
                       'wave_id': wave_id,
                       'width': width,
                       'height': height,
                       'theme_id': theme_id
                      }

    path = os.path.join(os.path.dirname(__file__), 'embed-template.html')
    self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication([('/', EmbedPage)], debug=False)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()